import * as VueRouter from 'vue-router'

// 懒加载
const Home = () => import('views/home/Home')
const Category = () => import('views/category/Category')
const Cart = () => import('views/cart/Cart')
const Profile = () => import('views/profile/Profile')
const Detail = ()=> import('views/detail/Detail')

const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    component: Home,
    meta: {
      keepAlive: true //设置页面是否需要使用缓存
    },
  },
  {
    path: '/category',
    component: Category,
    meta: {
      keepAlive: true //设置页面是否需要使用缓存
    },
  },
  {
    path: '/cart',
    component: Cart,
    meta: {
      keepAlive: true //设置页面是否需要使用缓存
    },
  },
  {
    path: '/profile',
    component: Profile,
    meta: {
      keepAlive: true //设置页面是否需要使用缓存
    },
  },
  {
    path: '/detail',
    component: Detail,
    meta: {
      keepAlive: false //设置页面是否需要使用缓存
    },
  }
]

const router = VueRouter.createRouter({
    history: VueRouter.createWebHashHistory(),
    routes
})

export default router
